using System;
using UnityEngine.InputSystem;
using static UnityEngine.InputSystem.InputAction;

namespace Inputs
{
    public class MapInput : GameInput<MapInput>, GameInputAction.IMapActions
    {
        public Action LockAction;
        public Action ResetAction;

        private void OnEnable()
        {
            InputActions.Map.Enable();
            InputActions.Map.SetCallbacks(this);
        }

        private void OnDisable()
        {
            InputActions.Map.Disable();
        }

        public void OnReset(CallbackContext context)
        {
            if (context.phase == InputActionPhase.Canceled)
                ResetAction?.Invoke();
        }

        public void OnLock(CallbackContext context)
        {
            if (context.phase == InputActionPhase.Canceled)
                LockAction?.Invoke();
        }
    }
}